package ObjectInputStream;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;

public class ObjectOutputStreamtest {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("./users");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        //oos.writeObject(new User("小米",20,true));
        List<User> list = new ArrayList<>();
        list.add(new User("小米",20,true));
        list.add(new User("小红",20,true));
        list.add(new User("小绿",20,true));
        oos.writeObject(list);
        oos.flush();
        oos.close();
    }
}
